package com.zyh.scs.admin.controller;

import com.zyh.scs.admin.api.dto.EarlyWarnDTO;
import com.zyh.scs.admin.service.UserEarlyWarnService;
import com.zyh.scs.common.core.util.R;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.AllArgsConstructor;
import org.springframework.http.HttpHeaders;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

/**
 * @author hwh
 * @ClassName: 预警提示访问层$
 * @Description: $
 * @Date $
 * @Version 1.0
 */
@RestController
@AllArgsConstructor
@RequestMapping("/earlyWarn")
@Tag(description = "earlyWarn", name = "预警提示模块")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class UserEarlyWarnController {

    private final UserEarlyWarnService userEarlyWarnService;

    /**
     * 待处理列表
     *
     * @return
     */
    @GetMapping("/getResultList")
    @Operation(summary = "待处理列表", description = "待处理列表")
    @PreAuthorize("@pms.hasPermission('scsx_early_warn_view')")
    public R getResultList() {
        return R.ok(userEarlyWarnService.getResultList());
    }


    /**
     * 历史操作记录列表
     *
     * @return
     */
    @GetMapping("/getHistoryAccount")
    @Operation(summary = "历史操作记录列表", description = "历史操作记录列表")
    @PreAuthorize("@pms.hasPermission('scsx_early_warn_view')")
    public R getHistoryAccount() {
        return R.ok(userEarlyWarnService.getHistoryAccount());
    }


    /**
     * 预警提示合并忽略操作
     *
     * @param earlyWarnDTO
     * @return
     */
    @PostMapping("/getMerge")
    @Operation(summary = "预警提示合并忽略操作", description = "预警提示合并忽略操作")
    @PreAuthorize("@pms.hasPermission('scsx_early_warn_edit')")
    public R getMerge(@Valid @RequestBody EarlyWarnDTO earlyWarnDTO) {
        return R.ok(userEarlyWarnService.getMerge(earlyWarnDTO));
    }

}
